//初始化云开发
wx.cloud.init({
  env: '自己修改',//cloud1-6g4fn1e1fc689993
})
const util=require('./utils/util')
App({
  async onLaunch () { 
    let device = wx.getSystemInfoSync()
    this.globalData.windowHeight=device.windowHeight-48
    this.globalData.windowWidth=device.windowWidth
    // console.log(this.globalData.windowWidth)
    // console.log(this.globalData.windowHeight)
    //获取屏幕亮度
    wx.getScreenBrightness({
      success(res){
        getApp().globalData.orignalBright=res.value;
      }
    })
    //费用管理
    let chargeConfig=await util.queryDbById('Settings','charge_manage')
    // console.log("价格："+chargeConfig.cost_each_time+"元/次")
    this.globalData.charge=chargeConfig.cost_each_time;
    // console.log('免费次数：'+chargeConfig.free_times)
    this.globalData.freeTimes=chargeConfig.free_times;

    // //查询API相关信息
    // var key=await util.queryDbById('Settings','bd_face_detect_token')
    // getApp().globalData.API.Access_Token=key.Access_Token
    // var timestamp = Math.round(Date.parse(new Date())/1000);//获取13位当前时间戳，/1000再向上取整，精确到秒
    // var gap=timestamp-key.lastUpdateTime
    // if(gap>=key.effictiveTime){//token超过有效期
    //   //重新获取access_token，更新全局数据global.data.API.Access_Token
    //   getApp().globalData.API.Access_Token = (await util.getAPIgrant(key))
    //   // console.log(getApp().globalData.API.Access_Token)
    // }

    //查询API相关信息
    // var key=util.queryDbById('Settings','bd_face_detect_token')
  },
  globalData: {
    themes:[
      {
        deepColor:"wux-royal",
        midColor:"wux-assertive",
        lightColor:"wux-energized",
        deepBgColor:'wux-royal--bg',
        midBgColor:'wux-assertive--bg',
        lightBgColor:'wux-energized--bg',
        deepBorderColor:"wux-energized--border",
        midBorderColor:"wux-assertive--border",
        lightBorderColor:"wux-royal--border"
      },
      {
        deepColor:"wux-positive",
        midColor:"wux-calm",
        lightColor:"wux-balanced",
        deepBgColor:'wux-positive--bg',
        midBgColor:'wux-calm--bg',
        lightBgColor:'wux-balanced--bg',
        deepBorderColor:"wux-positive--border",
        midBorderColor:"wux-calm--border",
        lightBorderColor:"wux-balanced--border"
      }
    ],
    presentTheme:{
      deepColor:"wux-royal",
      midColor:"wux-assertive",
      lightColor:"wux-energized",
      deepBgColor:'wux-royal--bg',
      midBgColor:'wux-assertive--bg',
      lightBgColor:'wux-energized--bg',
      deepBorderColor:"wux-energized--border",
      midBorderColor:"wux-assertive--border",
      lightBorderColor:"wux-royal--border"
    },
    // presentTheme:{
    //   deepColor:"wux-positive",
    //   midColor:"wux-calm",
    //   lightColor:"wux-balanced",
    //   deepBgColor:'wux-positive--bg',
    //   midBgColor:'wux-calm--bg',
    //   lightBgColor:'wux-balanced--bg',
    //   deepBorderColor:"wux-positive--border",
    //   midBorderColor:"wux-calm--border",
    //   lightBorderColor:"wux-balanced--border"
    // },
    windowHeight:0,
    windowWidth:0,
    hasUserInfo:false,
    userInfo: {
      avatarUrl:'',
      nickName:'',
      openId:'',//openId
      remainingTimes:0,//剩余次数
      skinAnalyzeInspect:'',//皮肤分析指标
      amount:0,//累计皮肤分析次数
      detectAllow:false//是否可直接检测
    },
    article:"",
    orignalBright:0.5,//初始屏幕亮度
    camera:{
      direction:'back'
    },
    charge:1,//1元/次
    freeTimes:5,//免费5次
    API:{
      Access_Token:'自己修改'//24.b3807ebe7d8afaee369aea9276f7a68c.2592000.1654354715.282335-26000642
    }
  },



})
